package com.odais.Reservation;

import java.util.Calendar;
import java.util.Date;

/**
 *
 * @author Lionel DECELLE
 * @since 8 juin 2012 - 10:51:23
 *
 */
public class Reservation
{
// ===========================================================
// Constants
// ===========================================================

// ===========================================================
// Fields
// ===========================================================
private int itemSqlID;
private String restoName;
private String clientName;
private int itemNPeople;
private int itemStatus;
private String itemNumRsv;
private int itemNumTable;
private String itemTimestampRsv;
private String itemInfo;

private Date date;
private String tmpDate, tmpHour;

// ===========================================================
// Constructors
// ===========================================================

public Reservation(String restoName, String clientName, int itemNPeople,
		int itemStatus, String itemNumRsv, int itemNumTable,
		String itemTimestampRsv, int itemSqlID, String itemInfo) {
	super();
	this.restoName = restoName;
	this.clientName = clientName;
	this.itemNPeople = itemNPeople;
	this.itemStatus = itemStatus;
	this.itemNumRsv = itemNumRsv;
	this.itemNumTable = itemNumTable;
	this.itemTimestampRsv = itemTimestampRsv;
	this.itemSqlID = itemSqlID;
	this.itemInfo = itemInfo;
	date = new Date();
	
	if(this.itemTimestampRsv != null)
	{
		
		RefreshDate();
	}
}

// ===========================================================
// Getter & Setter
// ===========================================================

	public String getRestoName() {
		return restoName;
	}

	public void setRestoName(String restoName) {
		this.restoName = restoName;
	}

	public String getClientName() {
		return clientName;
	}

	public void setClientName(String clientName) {
		this.clientName = clientName;
	}

	public int getItemNPeople() {
		return itemNPeople;
	}

	public void setItemNPeople(int itemNPeople) {
		this.itemNPeople = itemNPeople;
	}

	public int getItemStatus() {
		return itemStatus;
	}

	public void setItemStatus(int itemStatus) {
		this.itemStatus = itemStatus;
	}

	public String getItemNumRsv() {
		return itemNumRsv;
	}

	public void setItemNumRsv(String itemNumRsv) {
		this.itemNumRsv = itemNumRsv;
	}

	public int getItemNumTable() {
		return itemNumTable;
	}

	public void setItemNumTable(int itemNumTable) {
		this.itemNumTable = itemNumTable;
	}

	public String getItemDateRsv() {
		return itemTimestampRsv.replace("-", "").replace(":", "").replace(" ", "").substring(0, 8+0);
	}

	public String getItemHourRsv() {
		return itemTimestampRsv.replace("-", "").replace(":", "").replace(" ", "").substring(8, 8+6);
	}


	public int getItemSqlID() {
		return itemSqlID;
	}

	public void setItemSqlID(int itemSqlID) {
		this.itemSqlID = itemSqlID;
	}

	public String getItemTimestampRsv() {
		return itemTimestampRsv;
	}

	public void setItemTimestampRsv(String itemTimestampRsv) {
		this.itemTimestampRsv = itemTimestampRsv;
	}
	
	

	public String getItemInfo() {
		return itemInfo;
	}

	public void setItemInfo(String itemInfo) {
		this.itemInfo = itemInfo;
	}

	// ===========================================================
	// Methods for/from SuperClass/Interfaces
	// ===========================================================
	private void RefreshDate()
	{
		tmpDate = getItemDateRsv();
		tmpHour = getItemHourRsv();
		
		this.date.setDate(Integer.parseInt(tmpDate.substring(6, 6+2)));
		this.date.setMonth(Integer.parseInt(tmpDate.substring(4, 4+2)));
		this.date.setYear(Integer.parseInt(tmpDate.substring(0, 0+4)));
		this.date.setHours(Integer.parseInt(tmpHour.substring(0, 0+2)));
		this.date.setMinutes(Integer.parseInt(tmpHour.substring(2, 2+2)));
		this.date.setSeconds(Integer.parseInt(tmpHour.substring(4, 4+2)));
	}
	
	public Date getDate()
	{
		return this.date;
	}
	
}